/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.wii.elpro.dao.jpa;

import com.wii.elpro.dao.DepartemenDAOInterface;
import com.wii.elpro.dao.JPAUtil;
import com.wii.elpro.entity.Departemen;
import java.util.List;
import javax.persistence.EntityManager;

/**
 *
 * @author hendro
 */
public class DepartemenDAOImpl extends DAOGenericImpl implements DepartemenDAOInterface {

    public Departemen getDepartemen(long id) throws Exception {
        JPAUtil.beginTransaction();
        EntityManager em = JPAUtil.getEntityManager();
        try {
            return em.find(Departemen.class, id);
        } catch (Exception ex) {
            throw ex;
        }
    }

    public List<Departemen> getDepartemens() throws Exception {
        JPAUtil.beginTransaction();
        EntityManager em = JPAUtil.getEntityManager();
        try {
            return em.createQuery("SELECT d FROM Departemen d").getResultList();
        } catch (Exception ex) {
            throw ex;
        }
    }    
}
